home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / infor / tsptp.zip / IMATH.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-09  |  2KB  |  70 lines

  1. (******************************************************************************)
  2. (*                                 IMATH.MOD                                  *)
  3. (*                           Integer Math Benchmark.                          *)
  4. (******************************************************************************)
  5.  
  6. PROGRAM Imath(Output);
  7.  
  8. (******************************************************************************)
  9. (*                                TIMING                                      *)
  10. (******************************************************************************)
  11.  
  12. (*$IFNDEF TopSpeed *)
  13.  (*%F TRUE   *** Compile for Turbo Pascal ***)
  14.   USES TPBench;
  15.  (*%E*)
  16. (*$ELSE     *** Compile for TopSpeed Pascal ***)
  17.   IMPORT TSBench *;
  18. (*$ENDIF *)
  19.  
  20. (******************************************************************************)
  21.  
  22.   VAR X, Y : BmInt;
  23.  
  24.   PROCEDURE IntMath;
  25.     VAR I : BmInt;
  26.   BEGIN
  27.  
  28.     X := 0;
  29.     Y := 9;
  30.  
  31.     FOR I := 1 TO 30000 DO
  32.       X := X + (Y * Y - Y) DIV Y;
  33.  
  34.   END;
  35.  
  36. BEGIN
  37.   WriteLn('IntMath Benchmark');
  38.  
  39. (******************************************************************************)
  40. (*  Compute the looping overhead.  The Dummy procedure must have some side-   *)
  41. (*  effect so that it is not optimised out of existence.                      *)
  42. (******************************************************************************)
  43.  
  44.   StartTimer;                                   (* Start the clock.           *)
  45.  
  46.   REPEAT
  47.     Dummy;
  48.   UNTIL NullTimesUp;
  49.  
  50. (******************************************************************************)
  51. (*  Now run the benchmark.  Note that the Dummy procedure is also called so   *)
  52. (*  that we can eliminate its overhead from the looping overhead.             *)
  53. (******************************************************************************)
  54.  
  55.   StartTimer;                                   (* Start the clock.           *)
  56.  
  57.   REPEAT
  58.     Dummy;
  59.     IntMath
  60.   UNTIL BenchTimesUp;
  61.  
  62. (******************************************************************************)
  63.  
  64.   ReportTimes;
  65.  
  66.   WriteLn;
  67.   WriteLn('Result: X = ', X:0);
  68.  
  69. END.
  70.